In the previous
practice exercise, you practiced the
Do-While activity to create a guessing game. In this video, you will
understand the while activity. Let's get started. The
While activity enables the user to create a loop that executes the contained
steps repeatedly, while a specific
condition is met. The condition is evaluated before each execution
of the sequence. The main difference
between the While and the Do-While activity is
that in the While activity, the condition is evaluated before the body of
the loop is executed. This type of activity
can be useful to step through all the
elements of an array, or execute a particular
activity multiple times. The user can increment counters to browse through array indices, or step through
the list of items. For example, a program
to print the list of prime numbers up
to a given number. Break activity can be
used to exit the loop at any desired point even when the specified
condition is valid. In the next video, you will see a
demonstration where a program prompts the
user to input a number greater than one and
then it prints a list of prime numbers between one and the number
given by the user. I would encourage
you to go through the demonstration and attempt
to repeat it on your own. That's it for this video.
Thanks for watching.